﻿#include "broker.h"

Broker::Broker()
{

}

void Broker::takeOrder(OrderIntf *order)
{
    if(0 == order->execute()){
        orderRedo.push(order);
        orderUndo.clear();
    }
}

void Broker::redoOrder()
{
    if(orderRedo.length()){
        OrderIntf *order = orderRedo.pop();
        if(order->redo() == 0){
            orderUndo.push(order);
        }
    }
}

void Broker::undoOrder()
{
    if(orderUndo.length()){
        OrderIntf *order = orderUndo.pop();
        if(order->execute() == 0){
            orderRedo.push(order);
        }
    }
}
